package topo.autosearch;

import com.zhtelecom.common.snmp.SNMPTarget;
import com.zhtelecom.common.topograph.TopoDataSource;
import com.zhtelecom.nms.framework.discover.DiscoverAPI;
import java.util.List;
import topo.MainFrame;
import topo.utils.DialogTools;

public class ThreadNetSearch extends Thread {
    private List<String> subNetIPList;
    private List<SNMPTarget> snmpTargetList;
    private boolean isUsePing;

    public ThreadNetSearch(List<String> subNetIPList, List<SNMPTarget> snmpTargetList, boolean isUsePing) {
        this.subNetIPList = subNetIPList;
        this.snmpTargetList = snmpTargetList;
        this.isUsePing = isUsePing;
    }

    public void run() {
        try {
            MainFrame.source.clearAllData();
            InitDeviceTypeConfig.init();
            List deviceInfoList = DiscoverAPI.getDiscoverAPI().searchDeviceByNetList(this.subNetIPList, this.snmpTargetList, this.isUsePing);
            if ((deviceInfoList == null) || (deviceInfoList.size() < 1)) {
                DialogTools.showErroMsg(MainFrame.mainFrame, "没有搜索到设备");
                return;
            }
            List linkInfoList = DiscoverAPI.getDiscoverAPI().searchLinkInfo(deviceInfoList);
            InitTopo.initTopoNode(deviceInfoList);
            InitTopo.initTopoLink(linkInfoList);
        } catch (Exception e) {
            DialogTools.showErroMsg(MainFrame.mainFrame, "搜索设备出错!");
            e.printStackTrace();
        }
    }
}